/*
 * @Author: Aaron亚伦
 * @Wechat: a1319com
 * @Date: 2020-03-27 16:03:29
 * @FilePath: /golang/pachong/mobile.go
 * @Version: 1.0.0
 * @LastEditors: Aaron亚伦
 * @LastEditTime: 2020-04-15 14:12:14
 */
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"os"
	"regexp"
)

var (
	rePhone = `1[3456789]\d{9}`
)

func HandErr(err error, when string) {
	if err != nil {
		fmt.Println(when, err)
		os.Exit(1)
	}
}
func main() {
	resp, err := http.Get("https://www.haomagujia.com")
	HandErr(err, `http.Get`)
	bytes, _ := ioutil.ReadAll(resp.Body)
	html := string(bytes)
	// fmt.Println(html)

	re := regexp.MustCompile(rePhone)
	allString := re.FindAllStringSubmatch(html, -1)

	for _, x := range allString {
		fmt.Println(x)
	}

}
